package com.wyd.resourcetj.dao;

import java.util.List;

import javax.transaction.Transactional;

import com.wyd.resourcetj.model.Adminstrator;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

/**
 * IAdminstratorDao
 */
public interface IAdminstratorDao extends JpaRepository<Adminstrator, Integer>,JpaSpecificationExecutor<Adminstrator>{

    @Transactional
    @Modifying
   // @Query("update Users u set u.uname = ?2 where u.uid= ?1")  示例
    @Query("update Adminstrator a set a.password = :password where a.adminName= :adminName")
    
    int updateAdminstrator(String adminName,String password);

   /*  @Transactional
    @Modifying
   // @Query("update Users u set u.uname = ?2 where u.uid= ?1")  示例
    @Query("update Adminstrator a set a.exist = :exist where a.id= :id")
    
    int deleteAdminstrator(Integer id,Integer exist); */


    @Transactional
    @Modifying
    @Query("select  a from  Adminstrator a where a.adminName= :adminName and a.password = :password")  

    
    
    List<Adminstrator> login(String adminName ,String password);

    
}